<template>
	
	<view class="wrap">
		<view class="u-page">
			<u-form >
				<u-form-item :label-position="labelPosition" :label="taskAuditAdvice" label-width="150">
					<u-input  type="textarea" :border="border" :height="height" :auto-height="autoHeight" :placeholder="taskAuditAdvice" v-model="taskParam.auditAdvice" />
				</u-form-item>
				<u-form-item :label-position="labelPosition" :label="taskAuditAdvice" label-width="150">
					<u-input  type="textarea" :border="border" :height="height" :auto-height="autoHeight" :placeholder="taskAuditAdvice" v-model="taskParam.auditAdvice" />
				</u-form-item>
			</u-form>
			<u-row gutter="16" style="margin-top: 20rpx;">
				<u-col span="2">
				</u-col>
				<u-col span="4">
					<u-button type="success" @click="agree">{{$t('system.agree')}}</u-button>
				</u-col>
				<u-col span="4">
					<u-button type="error" @click="back">{{$t('system.back')}}</u-button>
				</u-col>
			</u-row>
		</view>
		<u-tabbar
			v-model="tabBar.current"  
			:list="tabBar.data" 
			@change="tabChange" 
			:inactive-color="tabBar.inactiveColor"
			:activeColor="tabBar.activeColor"
			></u-tabbar>
	</view>
	
</template>

<script>
	import request from "utils/request.js"
	export default {
		data() {
			return {
				// 审核意见
				taskAuditAdvice: this.$t('system.taskAuditAdvice'),
				// 是否显示边框
				border: false,
				advice: "",
				labelPosition: 'left',
				autoHeight: true,
				height: 100,
				taskInfo:{
					
				},
				// 流程变量
				processParam:{
					
				},
				// 任务变量
				taskParam:{
					// 审核意见
					auditAdvice: ""
				},
				tabBar:{
					inactiveColor: '#909399',
					activeColor: '#5098FF',
					data: [
						{
							iconPath: "edit-pen",
							selectedIconPath: "edit-pen",
							text: '任务',
							customIcon: false,
							
						},
						{
							iconPath: "order",
							selectedIconPath: "order",
							text: '历史',
							customIcon: false,
						},
					],
					current: 0,
				}
			}
		},
		onLoad(data) {
			debugger
			this.taskInfo = JSON.parse(data["taskInfo"])
		},
		methods: {
			// 同意
			agree(){
				let _this = this;
				this.processParam["isBack"] = false;
				this.taskParam["taskBack"] = false;
				const params = {
					taskId: this.taskInfo.taskId,
					comment: this.taskParam.auditAdvice,
					paramStr: JSON.stringify(this.taskParam),
					processParamStr: JSON.stringify(this.processParam)
				}
				request({
					url: '/flowable/workflow/completeTask',
					method: 'post',
					data: params
				}).then(response => {
					_this.$u.route({
						url: "/pages/main/main"
					})
				})
			},
			// 退回
			back(){
				let _this = this;
				this.processParam["isBack"] = true;
				this.taskParam["taskBack"] = true;
				var params = {
					taskId: this.taskInfo.taskId,
					processInstanceId: this.taskInfo.pocessInstanceId,
					comment: this.taskParam.auditAdvice,
					paramStr: JSON.stringify(this.taskParam),
					processParamStr: JSON.stringify(this.processParam)
				}
				request({
					url: '/flowable/workflow/rollback',
					method: 'post',
					data: params
				}).then(response => {
					_this.$u.route({
						url: "/pages/main/main"
					})
				})
			},
			tabChange(current){
				if(current == 1){
					this.$u.route({
						url: "/pages/flowable/task/common/task-history?taskInfo=" + JSON.stringify(this.taskInfo)
					})
				}
			}
		}
	}
</script>

<style>
</style>
